<!-- XHTML 1.0 Strict -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<meta name="author" content="Rachid Touzani" />
<meta name="keywords" content=" css, dropdowns, dropdown menu, drop-down, menu, navigation, nav, horizontal, vertical left-to-right, vertical right-to-left, horizontal linear, horizontal upwards, cross browser, internet explorer, ie, firefox, safari, opera, browser, lwis" />
<meta name="description" content="Clean, standards-friendly, modular framework for dropdown menus" />
<link href="../css/dropdown.vertical.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../css/default.ultimate.css" media="screen" rel="stylesheet" type="text/css" />

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Heat Transfer Demo 1</title>
<link rel="stylesheet" type="text/css" href="../doxygen.css" />
<link rel="stylesheet" type="text/css" href="../tabs.css"  />
</head>

<body bgcolor="#FFFFFF" link="#FF0000" vlink="#FF00FF" alink="#FF00FF">
<p align="center"><a href="../index.html"><img src="../im/ofeli.gif" width="150" border="0"></a></p>

<center>
  <div id="cse" style="width: 60%;">Loading</div>
  <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  <script type="text/javascript"> 
     google.load('search', '1', {language : 'en', style : google.loader.themes.SHINY});
     google.setOnLoadCallback(function() {
        var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
        '012396140824982761142:-qrywxcfi_o', customSearchOptions);
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        customSearchControl.draw('cse');
     }, true);
   </script>
   <style type="text/css">
     .gsc-control-cse {
     font-family: Verdana, sans-serif;
     border-color: #DAE0E5;
     background-color: #DAE0E5;
   }
   .gsc-control-cse .gsc-table-result { font-family: Verdana, sans-serif; }
   input.gsc-input { border-color: #B6BEC5; }
   input.gsc-search-button {
     border-color: #B6BEC5;
     background-color: #D0D1D4;
   }
   .gsc-tabHeader.gsc-tabhInactive {
     border-color: #999999;
     background-color: #EEEEEE;
   }
   .gsc-tabHeader.gsc-tabhActive {
     border-color: #999999;
     background-color: #999999;
   }
   .gsc-tabsArea { border-color: #999999; }
   .gsc-webResult.gsc-result,
   .gsc-results .gsc-imageResult {
     border-color: #FFFFFF;
     background-color: #FFFFFF;
   }
   .gsc-webResult.gsc-result:hover,
   .gsc-imageResult:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gsc-webResult.gsc-result.gsc-promotion:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gs-webResult.gs-result a.gs-title:link,
   .gs-webResult.gs-result a.gs-title:link b,
   .gs-imageResult a.gs-title:link,
   .gs-imageResult a.gs-title:link b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:visited,
   .gs-webResult.gs-result a.gs-title:visited b,
   .gs-imageResult a.gs-title:visited,
   .gs-imageResult a.gs-title:visited b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:hover,
   .gs-webResult.gs-result a.gs-title:hover b,
   .gs-imageResult a.gs-title:hover,
   .gs-imageResult a.gs-title:hover b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:active,
   .gs-webResult.gs-result a.gs-title:active b,
   .gs-imageResult a.gs-title:active,
   .gs-imageResult a.gs-title:active b { color: #0568CD; }
   .gsc-cursor-page { color: #0568CD; }
   a.gsc-trailing-more-results:link { color: #0568CD; }
   .gs-webResult .gs-snippet,
   .gs-imageResult .gs-snippet,
   .gs-fileFormatType { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl,
   .gs-imageResult div.gs-visibleUrl { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { display: none; }
   .gs-webResult div.gs-visibleUrl-long { display: block; }
   .gs-promotion div.gs-visibleUrl-short { display: none; }
   .gs-promotion div.gs-visibleUrl-long { display: block; }
   .gsc-cursor-box { border-color: #FFFFFF; }
   .gsc-results .gsc-cursor-box .gsc-cursor-page {
      border-color: #999999;
      background-color: #FFFFFF;
      color: #0568CD;
   }
   .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
      border-color: #999999;
      background-color: #999999;
      color: #0568CD;
   }
   .gsc-webResult.gsc-result.gsc-promotion {
      border-color: #D2D6DC;
      background-color: #D0D1D4;
   }
   .gsc-completion-title { color: #0568CD; }
   .gsc-completion-snippet { color: #5F6A73; }
   .gs-promotion a.gs-title:link,
   .gs-promotion a.gs-title:link *,
   .gs-promotion .gs-snippet a:link { color: #0066CC; }
   .gs-promotion a.gs-title:visited,
   .gs-promotion a.gs-title:visited *,
   .gs-promotion .gs-snippet a:visited { color: #0066CC; }
   .gs-promotion a.gs-title:hover,
   .gs-promotion a.gs-title:hover *,
   .gs-promotion .gs-snippet a:hover { color: #0066CC; }
   .gs-promotion a.gs-title:active,
   .gs-promotion a.gs-title:active *,
   .gs-promotion .gs-snippet a:active { color: #0066CC; }
   .gs-promotion .gs-snippet,
   .gs-promotion .gs-title .gs-promotion-title-right,
   .gs-promotion .gs-title .gs-promotion-title-right *  { color: #333333; }
   .gs-promotion .gs-visibleUrl,
   .gs-promotion .gs-visibleUrl-short { color: #5F6A73; }
   </style>
</center>
</p>
&nbsp;

<div id="mainmenu">
<div class="text">

 <div class="tabs">
   <ul class="tablist">
   <li><a href="../index.html"><span>Home</span></a>
   <li><a href="../overview.html"><span>Overview</span></a>
   <li><a href="../html/index.html"><span>Class Documentation</span></a>
   <li><a href="../fformats.html"><span>File Formats</span></a>
   <li><a href="../tutorial.html"><span>Tutorial</span></a>
   <li class="current"><a href="../demos.html"><span>Demo Codes</span></a>
 </div>

 </div>
 </div>

&nbsp;
<p>
<h2>Heat Transfer Demo 1: A 2-D steady state diffusion-convection code</h2>

<p><table border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="../demos.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="ttd2.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table>

<p>
<SPAN class=TEXT>
This code is developed to solve 2-D steady state diffusion-convection problems.
We use here a <i>user friendly</i> implementation. That is, rather than expliciting 
vector and matrix construction, matrix and right-hand side assembly, ... we
provide functions that perform all-in-one operations.
</SPAN>

<h2>The Program</h2>
<ul type="square">
<li><SPAN class=TEXT>The program starts by including the header file <span class=VAR>OFELI.h</span> that itself includes all kernel
class definitions, then we include thermal dedicated classes described in <span class=VAR>Therm.h</span>.
We also declare the namespace to simplify the code writing:</span><br>
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>#include "OFELI.h"
#include "Therm.h"
using namespace OFELI;</font></pre>
</td></tr>
</table></p>

<li><SPAN class=TEXT>We construct an instance of class <span class=VAR><a href="../html/classOFELI_1_1IPF.html">IPF</a></span> to manage project data.
The constructor enables giving the program name and release and the program argument is obtained here:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   IPF data("stdc2 - 2.0",argv[1]);</font></pre>
</td></tr>
</table>
</SPAN></p>

<li><SPAN class=TEXT>
The member function <span class=VAR>getVerbose()</span> returns the parameter that controls message output.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   if (data.getVerbose())
      ...</font></pre>
</td></tr>
</table>
</SPAN></p>

<li><SPAN class=TEXT>
We now read mesh data and construct an instance of class <span class=VAR><a href="../html/classOFELI_1_1Mesh.html">Mesh</a></span>
and an instance of class <span class=VAR><a href="../html/classOFELI_1_1Prescription.html">Prescription</a></span> to prescribe various data that we will
describe later. Note that these data prescription are provided in the file
<span class=VAR>data.getPrescriptionFile()</span>:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Mesh ms(data.getMeshFile(),true);
   Prescription p(ms,data.getPrescriptionFile());</font></pre>
</td></tr></table>
</span></p>

<li><SPAN class=TEXT>
Other types of data are the vectors that will contain problem data.
Here we choose a sparse storage in order to use an iterative solution method. Vector data
are the solution <span class=VAR>u</span>, Dirichlet boundary condition contained in <span class=VAR>
bc</span> and boundary fluxes (Neumann boundary conditions) in <span
class=VAR>bound_f</span>.
Note that the constructors of theses vectors use the 
<span class=VAR><a href="../html/classOFELI_1_1Mesh.html">Mesh</a></span> instance.
The vectors contain then mesh information.

<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Vect&lt;double&gt; u(ms,"Temperature");
   Vect&lt;double&gt; bc(ms), body_f(ms), bound_f(ms);
</td></tr></table></p>

<li><SPAN class=TEXT>
Vectors <span class=VAR>u</span>, <span class=VAR>bc</span> and <span class=VAR>bound_f</span>
are initialized from member function <span class=VAR>get</span> of the instance of 
class <span class=VAR>Prescription</span>:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   p.get(BOUNDARY_CONDITION,bc);
   p.get(SOURCE,body_f);
   p.get(FLUX,bound_f);</font></pre>
</td></tr></table></p>
<p>
Note that <span class=VAR>BOUNDARY_CONDITION</span>, <span class=VAR>SOURCE</span> and
<span class=VAR>FLUX</span> are integers defined in an <i>enum</i> variable. They enable selecting the
type of condition to enforce.</p>

<li><SPAN class=TEXT>
Since we deal with a diffusion-convection problem, we have to provide a velocity vector.
We first instantiate the velocity vector, check if the project file contains the flag for 
velocity. In this case, we read by using class <span class=VAR>IOField</span> the vector
<span class=VAR>v</span>:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Vect&lt;double&gt; v(ms,2);
   if (data.getInteger("v_flag")) {
      IOField ff(data.getMeshFile(),data.getString("v_file"),ms,IOField::IN);
      ff.get(v);
   }</font></pre>
</td></tr></table></p>

<li><SPAN class=TEXT>
We can now declare an equation. We instantiate class <span class=VAR>DC2DT3</span> that solves
diffusion-convection equations in 2-D using triangular P<sub>1</sub> (3-node) elements.
After instantiation, we transfer to the class various informations: the mesh, the vector 
<span class=VAR>u</span> that will contain solution at nodes, boundary condition vector, source vector,
and velocity vector.

<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   DC2DT3 eq;
   eq.setMesh(ms);
   eq.setInput(SOLUTION,u);
   eq.setInput(BOUNDARY_CONDITION,bc);
   eq.setInput(SOURCE,body_f);
   eq.setInput(FLUX,bound_f);
   eq.setInput(VELOCITY_FIELD,v);</font></pre>
</td></tr></table></p>

<li><SPAN class=TEXT>
With all these data, we can choose some options for the solver. Namely, we define the terms
in the equation (Diffusion and convection) and then choose an iterative solver (Gmres) coupled
with the ILU preconditioner. We then solve the problem by invoking the member function 
<span class=VAR>run</span>:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   eq.setTerms(DIFFUSION|CONVECTION);
   eq.setSolver(GMRES_SOLVER,ILU_PREC);
   int it = eq.run();</font></pre>
</td></tr></table></p>

<li><SPAN class=TEXT>
We end the program by outputting the solution and saving it for plotting purposes:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   if (data.getOutput() > 0)
      cout << u;
   if (data.getPlot()) {
      IOField pf(data.getPlotFile(),IOField::OUT);
      pf.put(u);
   }</font></pre>
</td></tr></table>
</ul></p>

&nbsp;&nbsp;
<h2>An example</h2>

<SPAN class=TEXT>
Let us run this program with the data presented in the following project file:
</span>
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>    &lt;Project name="proj"&gt;
       &lt;mesh_file&gt;proj.m&lt;/mesh_file&gt;
       &lt;parameter label="v_flag" value="1"/&gt;
       &lt;parameter label="v_file"&gt;proj.v&lt;/parameter&gt;
       &lt;plot_file&gt;proj.t&lt;/plot_file&gt;
       &lt;verbose&gt;1&lt;/verbose&gt;
       &lt;output&gt;1&lt;/output&gt;
       &lt;plot&gt;1&lt;/plot&gt;
    &lt;/Project&gt;
    &lt;Prescription&gt;
       &lt;BoundaryCondition code="1"&gt;1.0&lt;/BoundaryCondition&gt;
    &lt;/Prescription&gt;</font></pre>
</td></tr></table>
<p><SPAN class=TEXT>Let us give a brief description of this file contents:</span>

<ul>
<li type=circle><SPAN class=TEXT>
The project is called <span class=VAR>proj</span>. The name of a project yields some defaults for
parameters and file names.</span>
<li type=circle><SPAN class=TEXT>The mesh file is called <span class=VAR>proj.m</span>
<li type=circle><SPAN class=TEXT>We have a flag parameter that says that a velocity is present
for the convection contribution. This parameter can be retrieved by
the label <span class=VAR>v_flag</span></span>
<li type=circle><SPAN class=TEXT>The vector containing the given velocity field is present in 
the file <span class=VAR>proj.v</span>. This file name can be retrieved by the label 
<span class=VAR>proj.v</span></span>
<li type=circle><SPAN class=TEXT>The tag <span class=VAR>plot_file</span> refers to a string that will be
accessed in the <span class=VAR>IPF</span> class in order to define a file for storing the solution</span>
<li type=circle><SPAN class=TEXT>The next three lines describe parameters for message outputting,
solution output and the opportunity of storing the solution in a plot file</span>
<li type=circle><SPAN class=TEXT>Once the <span class=VAR>Project</span> tag is closed, we define a 
<span class=tt>Prescription</span> tag to define prescribed boundaty conditions. Here, the tag
<span class=tt>BoundaryCondition</span> chooses the type of prescription. The option <span class=VAR>
code</span> says that nodes with code equal to <span class=VAR>1</span> are concerned with the
prescription. Then, the value <span class=TT>1.0</span> is prescribed for this code.</span> 
</ul>

<p><table align="center" border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="../demos.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="ttd2.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table>

&nbsp;
<div id="foot_bar">
        Copyright &copy; 1998-2018 Rachid Touzani&nbsp;
</div>

</body>
</html>
